package rpc

import (
	//	"bytes"
	//	"encoding/binary"
	//"encoding/json"
	//	"fmt"
	"github.com/golang/glog"
	"github.com/oikomi/FishChatServer2/common/ecode"
	//commmodel "github.com/oikomi/FishChatServer2/common/model"
	"github.com/oikomi/FishChatServer2/protocol/rpc"
	//	"github.com/oikomi/FishChatServer2/server/manager/conf"
	//"github.com/oikomi/FishChatServer2/server/manager/dao"
	//"github.com/oikomi/FishChatServer2/server/manager/model"
	//sd "github.com/oikomi/FishChatServer2/service_discovery/etcd"
	"golang.org/x/net/context"
	//"google.golang.org/grpc"
	//	"net"
)

func (s *RPCServer) GetLogicIDByTableId(ctx context.Context, in *rpc.MGGetLogicIDReq) (res *rpc.MGGetLogicIDRes, err error) {
	glog.Info("GetLogicIDByTableId")
	tempRes, err := s.dao.Redis.GetTableInfo(ctx, in.TableID)
	if err != nil {
		glog.Error(err)
		res = &rpc.MGGetLogicIDRes{
			ErrCode: ecode.ServerErr.Uint32(),
			ErrStr:  ecode.ServerErr.String(),
		}

		return
	}
	res = &rpc.MGGetLogicIDRes{
		ErrCode:   ecode.OK.Uint32(),
		ErrStr:    ecode.OK.String(),
		LogicAddr: tempRes,
	}
	return
}
